eval(loadFile("main/src/viz.js"));

var coordinates;
var screen;
var graphics;

testCases(test,
    function setUp() {
        coordinates = viz.coordinates();
        screen = {
            widthOf : function (frameAsset) {
                return frameAsset.width;
            }
        };
        graphics = {};
    },

    function shouldBuildLocalCoordinateBasedOnZeroOrigin() {
        var frameAsset = {id : "asset1"};
        coordinates.addFrameAsset(frameAsset);

        var coordinate = coordinates.getCoordinateOf(frameAsset).localise(screen);
        assert.that(coordinate.x(), eq(0));
        assert.that(coordinate.x(10), eq(10));
        assert.that(coordinate.y(), eq(0));
        assert.that(coordinate.y(20), eq(20));
    },

    function shouldBuildLocalCoordinateNextToFrameAsset() {
        var previousFrameAsset = {id : "asset1", width : 25};
        var thisFrameAsset = {id : "asset2"};

        coordinates.addFrameAsset(previousFrameAsset);
        coordinates.addFrameAsset(thisFrameAsset).placedAfter(previousFrameAsset);

        var coordinate = coordinates.getCoordinateOf(thisFrameAsset).localise(screen);
        assert.that(coordinate.x(), eq(25));
        assert.that(coordinate.x(10), eq(35));
        assert.that(coordinate.y(), eq(0));
        assert.that(coordinate.y(20), eq(20));
    },

    function shouldBuildLocalCoordinateNextToFrameAssets() {
        var firstFrameAsset = {id : "asset1", width : 10};
        var secondFrameAsset = {id : "asset2", width : 15};
        var thirdFrameAsset = {id : "asset3"};

        coordinates.addFrameAsset(firstFrameAsset);
        coordinates.addFrameAsset(thirdFrameAsset).placedAfter(secondFrameAsset);
        coordinates.addFrameAsset(secondFrameAsset).placedAfter(firstFrameAsset);

        var coordinate = coordinates.getCoordinateOf(thirdFrameAsset).localise(screen);
        assert.that(coordinate.x(), eq(25));
        assert.that(coordinate.x(10), eq(35));
        assert.that(coordinate.y(), eq(0));
        assert.that(coordinate.y(20), eq(20));
    }
);